home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / e33min.zip / emacs / 19.33 / data / TUTORIAL < prev   
Text File  |  1996-06-14  |  39KB  |  918 lines

  1. Copyright (c) 1985 Free Software Foundation, Inc;  See end for conditions.
  2. You are looking at the Emacs tutorial.
  3.  
  4. Emacs commands generally involve the CONTROL key (sometimes labeled
  5. CTRL or CTL) or the META key (sometimes labeled EDIT or ALT).  Rather than
  6. write that in full each time, we'll use the following abbreviations:
  7.  
  8.  C-<chr>  means hold the CONTROL key while typing the character <chr>
  9.       Thus, C-f would be: hold the CONTROL key and type f.
  10.  M-<chr>  means hold the META or EDIT or ALT key down while typing <chr>.
  11.       If there is no META, EDIT or ALT key, instead press and release the
  12.       ESC key and then type <chr>.  We write <ESC> for the ESC key.
  13.  
  14. Important note: to end the Emacs session, type C-x C-c.  (Two characters.)
  15. The characters ">>" at the left margin indicate directions for you to
  16. try using a command.  For instance:
  17. <<Blank lines inserted here by startup of help-with-tutorial>>
  18. >>  Now type C-v (View next screen) to move to the next screen.
  19.     (go ahead, do it by depressing the control key and v together).
  20.     From now on, you'll be expected to do this whenever you finish
  21.     reading the screen.
  22.  
  23. Note that there is an overlap when going from screen to screen; this
  24. provides some continuity when moving through the file.
  25.  
  26. The first thing that you need to know is how to move around from
  27. place to place in the file.  You already know how to move forward a
  28. screen, with C-v.  To move backwards a screen, type M-v (depress the
  29. META key and type v, or type <ESC>v if you don't have a META or EDIT
  30. key).
  31.  
  32. >>  Try typing M-v and then C-v to move back and forth a few times.
  33.  
  34.  
  35. * SUMMARY
  36. ---------
  37.  
  38. The following commands are useful for viewing screenfuls:
  39.  
  40.     C-v    Move forward one screenful
  41.     M-v    Move backward one screenful
  42.     C-l    Clear screen and redisplay everything
  43.          putting the text near the cursor at the center.
  44.          (That's control-L, not control-1.)
  45.  
  46. >> Find the cursor and remember what text is near it.
  47.    Then type a C-l.
  48.    Find the cursor again and see what text is near it now.
  49.  
  50.  
  51. * BASIC CURSOR CONTROL
  52. ----------------------
  53.  
  54. Getting from screenful to screenful is useful, but how do you
  55. reposition yourself within a given screen to a specific place?
  56. There are several ways you can do this.  One way (not the best, but
  57. the most basic) is to use the commands previous, backward, forward
  58. and next.  As you can imagine these commands (which are given to
  59. Emacs as C-p, C-b, C-f, and C-n  respectively) move the cursor from
  60. where it currently is to a new place in the given direction.  Here,
  61. in a more graphical form are the commands:
  62.  
  63.               Previous line, C-p
  64.                   :
  65.                   :
  66.    Backward, C-b .... Current cursor position .... Forward, C-f
  67.                   :
  68.                   :
  69.               Next line, C-n
  70.  
  71. >> Move the cursor to the line in the middle of that diagram
  72.    and type C-l to see the whole diagram centered in the screen.
  73.  
  74. You'll probably find it easy to think of these by letter.  P for
  75. previous, N for next, B for backward and F for forward.  These are
  76. the basic cursor positioning commands and you'll be using them ALL
  77. the time so it would be of great benefit if you learn them now.
  78.  
  79. >> Do a few C-n's to bring the cursor down to this line.
  80.  
  81. >> Move into the line with C-f's and then up with C-p's.
  82.    See what C-p does when the cursor is in the middle of the line.
  83.  
  84. Lines are separated by Newline characters.  For most applications
  85. there should normally be a Newline character at the end of the text,
  86. as well, but it is up to you to make sure of this.  A file can
  87. validly exist without a Newline at the end.
  88.  
  89. >> Try to C-b at the beginning of a line.  Do a few more C-b's.
  90.    Then do C-f's back to the end of the line and beyond.
  91.  
  92. When you go off the top or bottom of the screen, the text beyond
  93. the edge is shifted onto the screen so that your instructions can
  94. be carried out while keeping the cursor on the screen.
  95.  
  96. >> Try to move the cursor off the bottom of the screen with C-n and
  97.    see what happens.
  98.  
  99. If moving by characters is too slow, you can move by words.  M-f
  100. (Meta-f) moves forward a word and M-b moves back a word.
  101.  
  102. >> Type a few M-f's and M-b's.  Intersperse them with C-f's and C-b's.
  103.  
  104. Notice the parallel between C-f and C-b on the one hand, and M-f and
  105. M-b on the other hand.  Very often Meta characters are used for
  106. operations related to English text whereas Control characters operate
  107. on the basic textual units that are independent of what you are
  108. editing (characters, lines, etc).  There is a similar parallel between
  109. lines and sentences: C-a and C-e move to the beginning or end of a
  110. line, and M-a and M-e move to the beginning or end of a sentence.
  111.  
  112. >> Try a couple of C-a's, and then a couple of C-e's.
  113.    Try a couple of M-a's, and then a couple of M-e's.
  114.  
  115. See how repeated C-a's do nothing, but repeated M-a's keep moving
  116. farther.  Do you think that this is right?
  117.  
  118. Two other simple cursor motion commands are M-< (Meta Less-than),
  119. which moves to the beginning of the file, and M-> (Meta Greater-than),
  120. which moves to the end of the file.  You probably don't need to try
  121. them, since finding this spot again will be boring.  On most terminals
  122. the "<" is above the comma and you must use the shift key to type it.
  123. On these terminals you must use the shift key to type M-< also;
  124. without the shift key, you would be typing M-comma.
  125.  
  126. The location of the cursor in the text is also called "point".  To
  127. paraphrase, the cursor shows on the screen where point is located in
  128. the text.
  129.  
  130. Here is a summary of simple moving operations including the word and
  131. sentence moving commands:
  132.  
  133.     C-f    Move forward a character
  134.     C-b    Move backward a character
  135.  
  136.     M-f    Move forward a word
  137.     M-b    Move backward a word
  138.  
  139.     C-n    Move to next line
  140.     C-p    Move to previous line
  141.  
  142.     C-a    Move to beginning of line
  143.     C-e    Move to end of line
  144.  
  145.     M-a    Move back to beginning of sentence
  146.     M-e    Move forward to end of sentence
  147.  
  148.     M-<    Go to beginning of file
  149.     M->    Go to end of file
  150.  
  151. >> Try all of these commands now a few times for practice.
  152.    Since the last two will take you away from this screen,
  153.    you can come back here with M-v's and C-v's.  These are
  154.    the most often used commands.
  155.  
  156. Like all other commands in Emacs, these commands can be given
  157. arguments which cause them to be executed repeatedly.  The way you
  158. give a command a repeat count is by typing C-u and then the digits
  159. before you type the command.  If you have a META or EDIT key, you can
  160. omit the C-u if you hold down the META or EDIT key while you type the
  161. digits.  This is easier, but we recommend the C-u method because it
  162. works on any terminal.
  163.  
  164. For instance, C-u 8 C-f moves forward eight characters.
  165.     
  166. >> Try giving a suitable argument to C-n or C-p to come as close
  167.    as you can to this line in one jump.
  168.  
  169. The only apparent exception to this is the screen moving commands,
  170. C-v and M-v.  When given an argument, they scroll the screen up or
  171. down by that many lines, rather than screenfuls.  This proves to be
  172. much more useful.
  173.  
  174. >> Try typing C-u 8 C-v now.
  175.  
  176. Did it scroll the screen up by 8 lines?  If you would like to
  177. scroll it down you can give an argument to M-v.
  178.  
  179. If you are using X Windows, there is probably a rectangular area
  180. called a scroll bar at the right hand side of the Emacs window.  You
  181. can scroll the text by clicking the mouse in the scroll bar.
  182.  
  183. >> Try pressing the middle button at the top of the highlighted area
  184. within the scroll bar, then moving the mouse while holding that button
  185. down.
  186.  
  187. >> Move the mouse to a point in the scroll bar about three lines from
  188. the top, and click the left button a couple of times.  Then try the
  189. right button a couple of times.
  190.  
  191.  
  192. * WHEN EMACS IS HUNG
  193. --------------------
  194.  
  195. If Emacs gets into an infinite (or simply very long) computation which
  196. you don't want to finish, you can stop it safely by typing C-g.
  197. You can also use C-g to discard a numeric argument or the beginning of
  198. a command that you don't want to finish.
  199.  
  200. >> Type C-u 100 to make a numeric arg of 100, then type C-g.
  201.    Now type C-f.  How many characters does it move?
  202.    If you have typed an <ESC> by mistake, you can get rid of it
  203.    with a C-g.
  204.  
  205. If you type <ESC> : then you get a new window appearing on the screen,
  206. telling you that M-: is a "disabled command" and asking whether you
  207. really want to execute i